using System.Collections.Generic;


namespace Core.Graphics
{
    public class TileSetCollection : Dictionary<int, TileSet>
    {
        //Global Collection of TileSets
        public static TileSetCollection GlobalTerrainTileSets
        {
            get { return _GlobalTerrainTileSets; } set { _GlobalTerrainTileSets = value; }
        }

        public static TileSetCollection GlobalCharacterTileSets
        {
            get { return _GlobalCharacterTileSets; } set { _GlobalCharacterTileSets = value; }
        }

        public static TileSetCollection GlobalItemTileSets
        {
            get { return _GlobalItemTileSets; } set { _GlobalItemTileSets = value; }
        }

        public static TileSetCollection GlobalEffectTileSets
        {
            get { return _GlobalEffectTileSets; } set { _GlobalEffectTileSets = value; }
        }

        private static TileSetCollection _GlobalTerrainTileSets = new TileSetCollection();
        private static TileSetCollection _GlobalCharacterTileSets = new TileSetCollection();
        private static TileSetCollection _GlobalItemTileSets = new TileSetCollection();
        private static TileSetCollection _GlobalEffectTileSets = new TileSetCollection();

        /// <summary>
        /// The Next ID for TileSets added to game
        /// </summary>
        public static int NextID
        {
            get { return _NextID; }
            set
            {   //if value set to equals current next id, or greater, set next id value to that + 1.
                if (value >= _NextID)
                    _NextID = value + 1;
            }
        }

        private static int _NextID;

        public static TileSetTile GetTile(TileID ID, TileSetTypes TileSetType)
        {
            TileSetCollection tsc = TileSetLoaderHelper.GetCollectionForType(TileSetType);

            if (ID == null)
                return TileSetTile.BlankTile;

            TileSetTile tst;
            if (ID.ID >= 0)
            {
                tst = tsc[ID.TileSetID].Tiles[ID.ID];
            }
            else
                tst = TileSetTile.BlankTile;


            return tst;
        }
    }
}
